package ezXpns;

import java.util.HashMap;

/**
 * 
 * @author A0086934R
 * 
 *         Report of basic statistics
 */

// @author A0086934R
public class Report {

	/**
	 * Constructor. Clears all stored data and reuse the Report instance
	 */
	public Report() {
		reset();
	}

	/**
	 * Returns the savings.
	 * 
	 * @return (income - expense)
	 */
	public float getSavings() {
		return income - expense;
	}

	/**
	 * Sets the total income
	 * 
	 * @param income
	 */
	public void setTotalIncome(float income) {
		this.income = income;
	}

	/**
	 * Returns the total income
	 * 
	 * @return income
	 */
	public float getTotalIncome() {
		return income;
	}

	/**
	 * Sets the total expense
	 * 
	 * @param expense
	 */
	public void setTotalExpense(float expense) {
		this.expense = expense;
	}

	/**
	 * Returns the total expense
	 * 
	 * @return expense
	 */
	public float getTotalExpense() {
		return expense;
	}

	/**
	 * Increase the income by the specified value
	 * 
	 * @param amount
	 *            to increase the income by
	 */
	public void changeIncome(float amount) {
		income += amount;
	}

	/**
	 * Increase the epxnse by the specified value
	 * 
	 * @param amount
	 *            to increase the expense by
	 */
	public void changeExpense(float amount) {
		expense += amount;
	}

	/**
	 * Adds new expense Type
	 * 
	 * @param name
	 *            of expense type
	 * @param value
	 */
	public void addExpenseType(String name, float value) {
		if (expenseMap.containsKey(name))
			expenseMap.put(name, value + expenseMap.get(name));
		else
			expenseMap.put(name, value);
	}

	/**
	 * Sets the hashmap used to map expense and its types
	 * 
	 * @param expenseHash
	 */
	public void setExpenseHash(HashMap<String, Float> expenseHash) {
		expenseMap = expenseHash;
	}

	/**
	 * Resets all stored data and clease the hashmap
	 */
	public void reset() {
		income = 0;
		expense = 0;
		expenseMap = new HashMap<String, Float>();
		tagHashMap = new HashMap<String, Float>();
	}

	private float income;
	private float expense;

	private HashMap<String, Float> expenseMap;
	private HashMap<String, Float> tagHashMap;

	public HashMap<String, Float> getExpenseHash() {
		return expenseMap;
	}

	public void setTagHash(HashMap<String, Float> entry) {
		tagHashMap = entry;

	}
	
	public HashMap<String, Float> getTagHash(){
		return tagHashMap;
		
	}
}
